using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebTools.UI.WebControls
{
	[ToolboxData("<{0}:DropDownListLabel runat=server></{0}:DropDownListLabel>")]
	public class DropDownListLabel : WebControlLabel<DropDownList>
	{
		protected override void SetCustomProperties(DropDownList control)
		{
			control.AppendDataBoundItems = this.AppendDataBoundItems;
			control.AutoPostBack = this.AutoPostBack;
			control.CausesValidation = this.CausesValidation;
			control.DataTextField = this.DataTextField;
			control.DataTextFormatString = this.DataTextFormatString;
			control.DataValueField = this.DataValueField;
			control.ValidationGroup = this.ValidationGroup;
			control.TextChanged += new EventHandler(this.InternalTextChanged);
			control.SelectedIndexChanged += this.SelectedIndexChanged;
		}

		#region Events

		public event EventHandler SelectedIndexChanged;

		#endregion

		#region Properties
		[DefaultValue(false)]
		[Themeable(false)]
		[Category("Behavior")]
		[Description("")]
		public virtual bool AppendDataBoundItems
		{
			get
			{
				object obj = this.ViewState["AppendDataBoundItems"];
				if (obj != null)
				{
					return (bool)obj;
				}
				return false;
			}
			set
			{
				this.ViewState["AppendDataBoundItems"] = value;
			}
		}

		[Description("")]
		[Themeable(false)]
		[DefaultValue(false)]
		[Category("Behavior")]
		public virtual bool AutoPostBack
		{
			get
			{
				object obj = this.ViewState["AutoPostBack"];
				if (obj != null)
				{
					return (bool)obj;
				}
				return false;
			}
			set
			{
				this.ViewState["AutoPostBack"] = value;
			}
		}

		[DefaultValue(false)]
		[Description("")]
		[Themeable(false)]
		[Category("Behavior")]
		public virtual bool CausesValidation
		{
			get
			{
				object obj = this.ViewState["CausesValidation"];
				if (obj != null)
				{
					return (bool)obj;
				}
				return false;
			}
			set
			{
				this.ViewState["CausesValidation"] = value;
			}
		}

		[Description("")]
		[DefaultValue("")]
		[Themeable(false)]
		[Category("Data")]
		public virtual string DataTextField
		{
			get
			{
				object obj = this.ViewState["DataTextField"];
				if (obj != null)
				{
					return (string)obj;
				}
				return string.Empty;
			}
			set
			{
				this.ViewState["DataTextField"] = value;
			}
		}

		[DefaultValue("")]
		[Themeable(false)]
		[Description("")]
		[Category("Data")]
		public virtual string DataTextFormatString
		{
			get
			{
				object obj = this.ViewState["DataTextFormatString"];
				if (obj != null)
				{
					return (string)obj;
				}
				return string.Empty;
			}
			set
			{
				this.ViewState["DataTextFormatString"] = value;
			}
		}

		[Description("")]
		[Themeable(false)]
		[DefaultValue("")]
		[Category("Data")]
		public virtual string DataValueField
		{
			get
			{
				object obj = this.ViewState["DataValueField"];
				if (obj != null)
				{
					return (string)obj;
				}
				return string.Empty;
			}
			set
			{
				this.ViewState["DataValueField"] = value;
			}
		}

		[DefaultValue((string)null)]
		[Category("Default")]
		[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
		[Description("")]
		[Editor("System.Web.UI.Design.WebControls.ListItemsCollectionEditor,System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
		[MergableProperty(false)]
		public virtual ListItemCollection Items
		{
			get { return this.InnerWebControl.Items; }
		}

		[Themeable(false)]
		[Category("Behavior")]
		[Bindable(true)]
		[Browsable(false)]
		[DefaultValue(0)]
		[Description("")]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual int SelectedIndex
		{
			get { return this.InnerWebControl.SelectedIndex; }
			set { this.InnerWebControl.SelectedIndex = value; }
		}

		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[Category("Behavior")]
		[Browsable(false)]
		[DefaultValue((string)null)]
		[Description("")]
		public virtual ListItem SelectedItem
		{
			get { return this.InnerWebControl.SelectedItem; }
		}

		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[Themeable(false)]
		[Description("")]
		[Category("Behavior")]
		[DefaultValue("")]
		[Bindable(true, BindingDirection.TwoWay)]
		public virtual string SelectedValue
		{
			get { return this.InnerWebControl.SelectedValue; }
			set { this.InnerWebControl.SelectedValue = value; }
		}

		[Description("")]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[Browsable(false)]
		[Themeable(false)]
		[DefaultValue("")]
		[Category("Behavior")]
		public override string Text
		{
			get
			{
				return this.SelectedValue;
			}
			set
			{
				this.SelectedValue = value;
			}
		}

		[Description("")]
		[Themeable(false)]
		[DefaultValue("")]
		[Category("Behavior")]
		public virtual string ValidationGroup
		{
			get
			{
				string text = (string)this.ViewState["ValidationGroup"];
				if (text != null)
				{
					return text;
				}
				return string.Empty;
			}
			set
			{
				this.ViewState["ValidationGroup"] = value;
			}
		}
		#endregion

	}
}
